package com.hzw.saas.api.property.enmus;

import java.util.Objects;

import cn.hutool.core.lang.Assert;

/**
 * 系统参数module
 *
 * @author zzl
 * @since 09/13/2021
 */
public enum SysParamModuleEnum {

    HOST("saas.host", "host"),
    EXCEPTION("saas.exception", "exception"),
    RBAC("saas.rbac", "权限模块"),
    SMS("saas.sms", "短信模块"),
    EMAIL("saas.email", "邮件模块"),
    VERIFY("saas.verify", "校验模块"),
    STORAGE("saas.storage", "存储模块"),
    PRODUCT("saas.product", "产品模块"),
    WECHAT_WEBSITE("wechat.website.saas","微信开放平台鸿之微云网站应用"),
    ;
    private final String module;
    private final String text;

    SysParamModuleEnum(String module, String text) {
        this.module = module;
        this.text = text;
    }

    public String getModule() {
        return module;
    }

    public String getText() {
        return text;
    }

    public static void assertValid(String module) {
        SysParamModuleEnum instance = instance(module);
        Assert.notNull(instance, "系统参数模块未知：{}", module);
    }

    public static SysParamModuleEnum instance(String module) {
        for (SysParamModuleEnum instance : SysParamModuleEnum.values()) {
            if (Objects.equals(instance.getModule(), module)) {
                return instance;
            }
        }
        return null;
    }
}
